package logic

import (
	"context"

	"xialou_platform/services/agent/rpc/agentClient"
	"xialou_platform/services/agent/rpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type AgentUserCountLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewAgentUserCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AgentUserCountLogic {
	return &AgentUserCountLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 绑定agent数据统计
func (l *AgentUserCountLogic) AgentUserCount(in *agentClient.AgentUserCountReq) (*agentClient.AgentUserCountResp, error) {
	userBindCount := l.svcCtx.AgentUserModel.FindListCount(l.ctx, in.AgentId, 1)

	return &agentClient.AgentUserCountResp{
		Base: &agentClient.BaseResp{
			Code: agentClient.RespCode_OK,
			Msg:  "success",
		},
		Data: &agentClient.AgentUserCountResp_Data{
			BindUserTotal: userBindCount,
		},
	}, nil
}
